home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / game / think / AmiChess.lha / AmiChess / src / hash.c < prev    next >
C/C++ Source or Header  |  2002-10-31  |  670b  |  30 lines

  1. #include "common.h"
  2.  
  3. void CalcHashKey()
  4. {
  5. short sq,piece,color;
  6. BitBoard b;
  7. PawnHashKey=HashKey=(HashType)0;
  8. for(color=white;color<=black;color++)
  9.     {
  10.     for(piece=pawn;piece<=king;piece++)
  11.         {
  12.         b=board.b[color][piece];
  13.         while(b)
  14.             {
  15.             sq=leadz(b);
  16.             CLEARBIT(b,sq);
  17.             HashKey^=hashcode[color][piece][sq];
  18.             if(piece==pawn) PawnHashKey^=hashcode[color][piece][sq];
  19.             }
  20.         }
  21.     }
  22. if(board.ep>-1) HashKey^=ephash[board.ep];
  23. if(board.flag&WKINGCASTLE) HashKey^=WKCastlehash;
  24. if(board.flag&WQUEENCASTLE) HashKey^=WQCastlehash;
  25. if(board.flag&BKINGCASTLE) HashKey^=BKCastlehash;
  26. if(board.flag&BQUEENCASTLE) HashKey^=BQCastlehash;
  27. if(board.side==black) HashKey^=Sidehash;
  28. }
  29.  
  30.